unit uCon_TaxaCartao;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, Formulario_Padrao_Consulta, TFlatButtonUnit, StdCtrls, Buttons,
  ExtCtrls, DB, Grids, DBGrids, DBTables;

type
  TfrmConTaxaCartao = class(TFrmConsulta)
    Label1: TLabel;
    edtDescricao: TEdit;
    DBGrid1: TDBGrid;
    ds: TDataSource;
    procedure edtDescricaoKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure FormActivate(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure BtnFecharClick(Sender: TObject);
    procedure DBGrid1DblClick(Sender: TObject);
  private
    { Private declarations }
    tq: TQuery;
    procedure FazConsulta;
  public
    { Public declarations }
    ID_TAXA: string;
  end;

var
  frmConTaxaCartao: TfrmConTaxaCartao;

implementation

uses clsTaxa_Cartao, dm, Biblio;

var
  TaxaCartao: TTAXA_CARTAO;

{$R *.dfm}

  { TfrmConTaxaCartao }

procedure TfrmConTaxaCartao.FazConsulta;
begin
  if edtDescricao.Text = '' then
    edtDescricao.Text := ' ';
  TaxaCartao.Consultar(tq, edtDescricao.Text);
  ds.DataSet := tq;
end;

procedure TfrmConTaxaCartao.edtDescricaoKeyDown(Sender: TObject;
  var Key: Word; Shift: TShiftState);
begin
  inherited;
  if key = 12 then FazConsulta;
end;

procedure TfrmConTaxaCartao.FormActivate(Sender: TObject);
begin
  inherited;
  tq := TQuery.create(DmInt);
  tq.DatabaseName := DmInt.Db.DatabaseName;
  TaxaCartao := TTAXA_CARTAO.Create;
  FazConsulta();
  edtDescricao.Clear;
  edtDescricao.SetFocus;

end;

procedure TfrmConTaxaCartao.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
  inherited;
  tq.Free;
  TaxaCartao.Free;
end;

procedure TfrmConTaxaCartao.BtnFecharClick(Sender: TObject);
begin
  inherited;
  ID_TAXA := StrZero(tq.FieldByName('ID_TAXA').AsInteger, 3);
end;

procedure TfrmConTaxaCartao.DBGrid1DblClick(Sender: TObject);
begin
  inherited;
  BtnFecharClick(Sender);
end;

end.

